//
//  GraduatedScaleView.m
//  分享demo
//
//  Created by pc-chtypd056 on 2018/8/6.
//  Copyright © 2018年 CTL. All rights reserved.
//

#import "GraduatedScaleView.h"
#import "GraduatedScaleViewController.h"

@interface GraduatedScaleView()

@property (nonatomic, strong) UILabel *label;

@end

@implementation GraduatedScaleView

- (instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        [self setUpSubViews];
    }
    return self;
}

- (void)setUpSubViews{
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:@"刻度尺" forState:UIControlStateNormal];
    button.frame = CGRectMake(0, 0, ScreenWIDTH, 35);
    [button addTarget:self action:@selector(buttonClickEvent:) forControlEvents:UIControlEventTouchUpInside];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [self addSubview:button];
    button.center = self.center;
    
    _label = [[UILabel alloc]initWithFrame:CGRectMake(0, 150, ScreenWIDTH, 35)];
    _label.textColor = [UIColor redColor];
    _label.textAlignment = NSTextAlignmentCenter;
    [self addSubview:_label];
}

- (void)buttonClickEvent:(UIButton *)button{
    
    GraduatedScaleViewController *gsVC = [GraduatedScaleViewController graduatedScaleWithBlock:^(NSInteger scale) {
        NSLog(@"scale:%ld",(long)scale);
        self->_label.text = [NSString stringWithFormat:@"%ld",scale];
    }];
    [[Tools getCurrentViewController:self]presentViewController:gsVC animated:NO completion:nil];
}

@end
